home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dbase / techs.zip / TECH16.ZIP / BACKUP.PRG next >
Text File  |  1985-11-02  |  3KB  |  98 lines

  1. * Program..: Backup.PRG
  2. * Author...: Ray Love
  3. * Date.....: May 1, 1985
  4. * Version..: dBASE III, any version
  5. * Note(s)..: This program is used to back up large files to
  6. *            floppies in drive A: from a hard disk.  The
  7. *            disks are numbered and date-stamped.
  8. *
  9. SET TALK OFF
  10. STORE "A:" TO drive
  11. * ---Build a line from graphics characters.
  12. STORE CHR( 205 ) TO line
  13. STORE line + line + line + line + line TO line
  14. STORE line+line+line+line+line+line+line+line TO line
  15. CLEAR
  16. @  1, 0 SAY CHR( 201 ) + line
  17. @  1,39 SAY line + CHR( 187 )
  18. @  2, 0 SAY CHR( 186 )
  19. @  2,79 SAY CHR( 186 )
  20. @  2,30 SAY "F I L E    B A C K U P"
  21. @  2,68 SAY DATE()
  22. @  3, 0 SAY CHR( 200 ) + line
  23. @  3,39 SAY line + CHR( 188 )
  24. *
  25. * ---Get file to use.
  26. mfile = SPACE( 8 )
  27. rec_size = 2
  28. done = .F.
  29. DO WHILE mfile = SPACE( 8 )
  30.    @ 11,15 SAY "Enter the file to backup.";
  31.            GET mfile PICTURE "@!"
  32.    @ 11,52 SAY "'Q' TO EXIT."
  33.    READ
  34.    IF TRIM( mfile ) = "Q"
  35.       SET TALK ON
  36.       done = .T.
  37.       EXIT
  38.    ENDIF
  39.    @ 13,10 SAY "Number of bytes per record = ";
  40.            GET rec_size RANGE 2,4000
  41.    READ
  42.    mfile = TRIM( mfile ) + ".DBF"
  43.    IF .NOT. FILE( "&mfile" )
  44.       @ 23,20 SAY mfile + " File does not exist.  Please re-enter"
  45.       mfile = SPACE( 8 )
  46.    ENDIF
  47. ENDDO
  48. * ---The memory variable, done, is used to EXIT the loop and
  49. * ---RETURN from the program after the loop.  It is coded this
  50. * ---way because of the anomaly on RETURNing from within a
  51. * ---DO WHILE loop.  See page D3-32 of the April 1985 issue of
  52. * ---TechNotes for further discussion of this anomaly.
  53. IF done
  54.    RETURN
  55. ENDIF
  56. *
  57. * ---Calculate number of records per disk to copy,
  58. * ---leaving room for the file header.
  59. * ---If you are using the 1.2 MB floppy on the IBM PC AT,
  60. * ---change 350000 to 1200000.
  61. recs_copy = INT( 350000 / rec_size )
  62. *
  63. * ---Clear screen from 4th row to the end.
  64. @ 4,0 CLEAR
  65. * ---Make the backup files.
  66. USE &mfile
  67. STORE 1 TO disk
  68. DO WHILE .NOT. EOF()
  69.    STORE " " TO ready
  70.    @ 5,15 SAY "Insert a blank formatted disk in drive " + drive
  71.    @ 6,15 SAY "Use a new disk for each " +;
  72.               STR( recs_copy) + " records to back up."
  73.    @ 7,15 SAY "Hit any key to begin copying " + mfile + ".";
  74.           GET ready
  75.    READ
  76.    @ 5,15 CLEAR
  77.    * ---Backup filename is in the format: FF-MM-DD.999
  78.    * ---where FF is the first two characters of the file,
  79.    * ---MM-DD is the current date,
  80.    * ---.999 is the disk number.
  81.    backup = drive + SUBSTR(mfile,1,2) + "-" + ;
  82.       SUBSTR( DTOC( DATE() ),1,2 ) + "-" + ;
  83.       SUBSTR( DTOC( DATE() ),4,2 ) + "." + STR( disk,1 )
  84.    @ 4,0
  85.    SET TALK ON
  86.    ? "Copying Next " + STR( recs_copy) + " TO " + backup
  87.    COPY NEXT recs_copy TO &backup
  88.    SET TALK OFF
  89.    @ 5,0 CLEAR
  90.    IF .NOT. EOF()
  91.       SKIP
  92.    ENDIF
  93.    disk = disk + 1
  94. ENDDO
  95. CLOSE DATABASES
  96. SET TALK ON
  97. RETURN
  98. * EOP Backup.PRG